/*
*@date:20180902
*@author: wj 
*@description: 按YLJ的接口文档《测试接口文档.docx》，15.违法行为代码查询 底层cmd：04C91
*/
<template>
    <div class="sys-page">
        <app-title :title="dialogTitle"></app-title>
        <app-notes>违法行为代码查询</app-notes>
        <el-row>
            <el-col :span="20">
                <app-search>
                    <el-form :inline="true" :model="searchForm" :rules="searchRules" ref="searchForm">
                        <el-form-item label="违法代码" prop="id">
                            <el-input v-model="searchForm.id"  ref="id" :disabled="false"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="search">查询</el-button>
                        </el-form-item>
                    </el-form>
                </app-search>
            </el-col>
        </el-row>    
            <el-table v-loading="loading" border :data="tableData" :row-class-name="tableRowClassName">         
                <el-table-column label="查询结果" width="580" prop="result"></el-table-column>
            </el-table>
            <el-alert :title="errorMsg" type="warning" :closable="false" show-icon v-show="!reliable"> </el-alert>
    </div>
</template>
<style>
  .el-table .warning-row {
    background: #F08080;
  }

  .el-table .success-row {
    background:#f0f9eb;
  }
</style>

<script>
export default {
    data(){
        return {
            url: '../../trffweb/services/TmriOutAccess/queryObjectOut15.shtml',
            dialogTitle:"违法行为代码查询",
            loading: false,
            tableData:[],
            errorMsg:"您的信息有误，请联系管理员修改",
            reliable:true,
            searchForm: {
                xtlb: '01',
                jkxlh: '791F0909030617040815E6958E9DFF8FFC9E39343238575840746D72692E636E',
                jkid: '04C91',
                type: '15',
                id: ''
            },

             searchRules: {
                id: [
                    { required:true, message: '请输入违法代码编号', trigger: 'blur' }
                ]
            }

       }
    },
    mounted(){
    },
    methods:{
        tableRowClassName({row, rowIndex}) {
          if(this.reliable === false){
            return 'warning-row';
          }else{
              return 'success-row'
          }
        },
        search(){
            this.$refs.searchForm.validate((valid)=>
            {
                if(valid){
                    if(this.searchForm.id == '1209') {
                        this.tableData = [{
                            result: '1209: 左转弯时，未靠路口中心点左侧转弯的,罚款100，扣2分'
                        }]
                        return
                    }
                    
                    this.HTTP.methods.apiPost(this.url, this.searchForm).then(res =>
                    {
                        if(res.code != 200){
                            this.$message({
                            message: res.msg,
                            type: 'error'
                            })                              
                        }else{
                            this.tableData = res.data
                            this.loading = false
                        }
                    })
                }
            })                
        }
    }
}
</script>

    
